/**
 * related to tododetail.ui
 * 
 * @Author : mafeng
 * @Timestamp : 2017-11-13
 */
var util=require("ui/util");
util.init("do_ALayout_back");
var do_App = sm("do_App");
var do_Page = sm("do_Page");
var do_DataCache = sm("do_DataCache");
var do_Notification = sm("do_Notification");
var dialog  = sm("do_Dialog")

var listview = ui("do_ListView_1");
var alert_layout = ui("do_ALayout_26");
alert_layout.visible = false;

var getdata = do_Page.getData();

var onedata = getdata.detaildata;
var type = getdata.type;

ui("do_Label_3").text = "收费编码： " + onedata.sfbm;
ui("do_Label_4").text = "发送人： " + onedata.CreateUserName;
ui("do_Label_8").text = "报修说明： " + onedata.Gz_remarks;
ui("do_Label_9").text = "状态： " + onedata.StatueName;
ui("do_Label_10").text = "" + onedata.Gz_name;
ui("do_Label_14").text = "换热站： " + onedata.hrz_name;
ui("do_Label_6").text = "送达时间： " + onedata.PaiDanTime;
ui("do_Label_7").text = "报修时间： " + onedata.BaoXiuTime;
ui("do_Label_5").text = "派单人： " + onedata.PaiSongRen;
ui("do_Label_6").text = "送达时间： " + onedata.PaiDanTime;
ui("do_Label_11").text = onedata.Man_name;
ui("do_Label_12").text = onedata.Phone;
ui("do_Label_13").text = onedata.All_name;

// item
var listdataTabs = mm("do_ListData");
deviceone.print(type);
if (type == "GetAllFinishWork" || type == "GetGongDanByUserIdFinish") {
	listdata = [
	            {
	            	title : "查看流程"
	            }
	            ];
} else {
	listdata = [
	            {
				title : "查看流程"
	            	},
	            {
	            	title : "发送"
	            },
	            {
	            	title : "处理"
	            },
	            {
	            	title : "退回"
	            }
	            ];
}

listdataTabs.addData(listdata);
listview.bindItems(listdataTabs);
listview.refreshItems({});

ui("do_ALayout_6").on("touch", function (data) {
		alert_layout.visible = !alert_layout.visible
})

// 选择item
listview.on("touch", function (data) {
	deviceone.print(JSON.stringify(data))
	if (data == 0) {
		// 查看流程
		do_App.openPage({
			source: "source://view/todoReceipt/webview/processwebview.ui",
			statusBarState: "transparent",
			animationType: "push_r2l",
			data: {
				mainid: onedata.mainID
			}
		});
		
		
	} else if (data == 1) {
		
		// 发送
		dialog.open("source://view/todoReceipt/send/sendui.ui", {lh : ""}, function (data, e) {
			
		})
		
	} else if (data == 2) {
		
		// 处理
		do_App.openPage({
			source: "source://view/todoReceipt/handlepage/handlepage.ui",
			statusBarState: "transparent",
			animationType: "push_r2l",
			data: {
				maindata: onedata
			}
		});
		
	} else if (data == 3) {
		
		// 退回
		dialog.open("source://view/todoReceipt/back/back.ui", {lh : ""}, function (data, e) {
			
		})
	}
	
});

